package com.tg.base.concurrent.future;

import java.util.concurrent.Callable;
import java.util.concurrent.TimeUnit;

/**
 * Created by MagicBook on 2020/2/1.
 */
public class GetBlock implements Callable<String> {
    /**
     * 执行次数
     */
    private static Integer count = 0;

    private Integer id;

    public GetBlock(Integer id) {
        this.id = id;
    }

    @Override
    public String call() throws Exception {
        System.out.println("执行中" + count++);

//        threadSleep(60 * 1000 * 5);
        threadSleep(500);
        return id.toString();
    }

    private static void threadSleep(long ms) {
        try {
            TimeUnit.MILLISECONDS.sleep(ms);
        } catch (InterruptedException ex) {

        }
    }
}
